<template>
    <div>
        <div id="main" style="width: 300px;height:300px;"></div>

    </div>
</template>

<script>
export default {
    props: {
        type: String
    },
    methods: {
        getcharts() {
            var myChart = this.$echarts.init(document.getElementById('main'));
            // 绘制图表
            myChart.setOption({
                title: {
                    text: '学生比例'
                },
                series: [
                    {
                        name: '销量',
                        type: 'pie',
                        data: [
                            {
                                value: 335,
                                name: '江苏'
                            },
                            {
                                value: 234,
                                name: '福建'
                            },
                            {
                                value: 1548,
                                name: '浙江'
                            }
                        ],
                        radius: '50%'
                    }
                ]
            });
        }

    },
    mounted() {
        this.getcharts(); // 在组件挂载后调用绘制图表的方法 
    },

}
</script>

<style scoped></style>